import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgentQuery, AgentVO, addOrEditForm } from './types';

/**
 * 查询代理商列表
 * @param query
 */
export const agentList = (query: AgentQuery): AxiosPromise<AgentVO[]> => {
  return request({
    url: '/payment/channel/list',
    method: 'get',
    params: query
  });
};


/**
 * 添加代理商
 */
export const addCerchant = (data:addOrEditForm) => {
  return request({
    url: '/payment/channel',
    method: 'post',
    data,
  });
};

/**
 * 代理商详情
*/
export const channelDetail = (id:string|number) => {
  return request({
    url: `/payment/channel/${id}`,
    method: 'get',
  });
};




/**
 * 获取代理商级别
*/
export const getDwLevel = () => {
  return request({
    url: `/payment/channel/getDwLevel`,
    method: 'get',
  });
};

/**
 * 审核代理商
*/
export const checkChannel = (data) => {
  return request({
    url: `/payment/channel/chk`,
    method: 'post',
    headers: {
    	  'Content-Type': 'application/x-www-form-urlencoded'
    },
    data
  });
};





/**
 * 修改代理商
 */
export const editCerchant = (data:addOrEditForm) => {
  return request({
    url: '/payment/channel',
    method: 'put',
    data,
  });
};

export default {
  agentList,
  addCerchant,
  channelDetail,
  editCerchant,
  checkChannel,
  getDwLevel
};
